﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using RedDragon.RBAC.API.Application.Common.Client;
using RedDragon.RBAC.API.Application.Common.Sale;
using T.Common.Domain.Common;

namespace RedDragon.RBAC.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class SaleController : ControllerBase
    {
        /// <summary>
        /// 
        /// </summary>
        private readonly IMediator mediator;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="mediator">mediator</param>
        public SaleController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 销售订单添加
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> addSale(AddSaleCommand cmd)
        {
            return await mediator.Send(cmd);
        }

        /// <summary>
        /// 销售列表
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> showSale(ShowSaleCommand cmd)
        {
            return await mediator.Send(cmd);
        }

        /// <summary>
        /// 根据销售订单id获取信息
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> FindSale(FindSaleCommand cmd)
        {
            return await mediator.Send(cmd);
        }






        /// <summary>
        /// 订单修改
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<Result> updateSale(UpdateSaleCommand cmd)
        {
            return await mediator.Send(cmd);
        }

       










        /// <summary>
        /// 订单删除
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<Result> deleteSale(DeleteSaleCommand cmd)
        {
            return await mediator.Send(cmd);
        }




    }
}
